/**登陆后，右侧抽屉内的按照日期排列的任务列表 */
import React from 'react';
import { List, Badge } from 'antd';
import './index.less';
import {connect} from 'react-redux';
import {get_day_task} from '../../../redux/action/actions';
import {getDateMark} from '../../../utils/getDateMark';

const TaskListDate = (props) => {
  const handleClick = (e) => {
    props.get_day_task(getDateMark(e.target.innerHTML));
  }
  return (
    <List
      onClick={handleClick}
      bordered
      dataSource={props.dateList}
      // rowKey={item=>item}
      renderItem={(item, index) => (
        <List.Item className="task_list_date_li">
          {item}
          <Badge count={props.task.length > 0 ? props.task[index].newTask.length : 0} style={{ backgroundColor: '#f50', marginLeft: '6px' }} />
        </List.Item>
      )}
    />
  )
}

export default connect(
  state => state,
  {get_day_task}
)(TaskListDate);
